[turf/buffer] Expose BufferOp's endCapStyle overload for line-type buffers #2937
+150
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello all, this is my first PR and contribution to an open-source project!
I love this library and I've been using it in a big project at work. One thing that always bugged me was that there was seemingly no way to opt out of the default rounded ends on line-type buffers. I've written my own line-buffer logic and I've tried using multiple turf line offsets to build 'buffered' geometries, all with the goal of achieving flat end caps that don't overshoot the end vertices' extents. I've struggled with reprojection issues, and I've always felt that
turf/bufferwas missing something.I did some digging, and it turns out that the JSTS library's BufferOp actually supports specifying and
endCapStyleinternally, but it was never exposed as an option inturf/bufferfor some reason.This PR introduces an optional
endCapStylebuffer option that defaults its behaviour to the current, always-round implementation. There are no breaking changes with this PR, and I wrote what I think are a fairly comprehensive set of tests to make sure that is the case.Please point out if I've overlooked anything but I think this is a pretty simple enhancement without any backwards compatibility issues.
Thanks for taking a look!